package com.rockwell.sniffyHunter.test;

import java.util.Map;
import java.util.HashMap;

import junit.framework.Assert;

import android.annotation.SuppressLint;
import com.rockwell.sniffyhunter.model.MoveBackToSniff;
import com.rockwell.sniffyhunter.model.Robot;
import com.rockwell.sniffyhunter.utils.DetectionIndex;
import com.rockwell.sniffyhunter.utils.IDetector;
import com.rockwell.sniffyhunter.utils.IRobotCommander;
import com.rockwell.sniffyhunter.utils.IRobotSensors;
import com.rockwell.sniffyhunter.utils.MoveBackToSniffState;

public class Pick_MoveBackToStartPtTester extends UnitTestLooper {
	private IRobotSensors 			sensor;
	private Map<Integer, IDetector>	colorDetectors;
	private FakeTreasureDetector	treasureDetector;
	private FakeTreasureCollector 	treasureCollector;
	private IRobotCommander 		robotCommander;
	private Robot 					robot;
	private MoveBackToSniff 		pick_moveBackToStartPtObj;
	
	@SuppressLint("UseSparseArrays") @SuppressWarnings("serial")
	@Override
	public void setUp() {
		sensor 						= new FakeRobotSensors();
		treasureDetector			= new FakeTreasureDetector();
		colorDetectors 				= new HashMap<Integer, IDetector>() {
									  {
										  put(DetectionIndex.TREASURE, treasureDetector);
										  put(DetectionIndex.OBSTACLE, new FakeColorDetector()/*obstacle detector*/); 
										  put(DetectionIndex.MAZE1, new FakeColorDetector()/*maze1 detector*/);
										  put(DetectionIndex.MAZE2, new FakeColorDetector()/*maze2 detector*/);
										  put(DetectionIndex.MAZE3, new FakeColorDetector()/*maze3 detector*/);
										  put(DetectionIndex.DROPZONE, new FakeColorDetector()/*dropZone detector*/);
										  put(DetectionIndex.MAZE_EXIT, new FakeColorDetector()/*dropZone detector*/);
									  }};
        robotCommander 				= new DummyRobotCommander();
		treasureCollector 			= new FakeTreasureCollector();
		robot 						= new Robot(0, 0, 
										1 /*start Zone*/,
										sensor, 
										robotCommander, 
										null/*maze*/, 
										null/*solver*/, 
										colorDetectors,
										treasureCollector);
		pick_moveBackToStartPtObj	= new MoveBackToSniff(robot);
	}
	
	@Override
	public void tearDown() {

	}
	
	public void testPick_MoveBackToStartPtState() {
		Assert.assertEquals(pick_moveBackToStartPtObj.getStateMachine(), MoveBackToSniffState.START);
		pick_moveBackToStartPtObj.PerformAction();
		Assert.assertEquals(pick_moveBackToStartPtObj.getStateMachine(), MoveBackToSniffState.MOVE_BACK);

		loopUntilCondition(pick_moveBackToStartPtObj, MoveBackToSniffState.START);
		Assert.assertEquals(pick_moveBackToStartPtObj.getStateMachine(), MoveBackToSniffState.START);
		
		pick_moveBackToStartPtObj.PerformAction();
		Assert.assertEquals(pick_moveBackToStartPtObj.getStateMachine(), MoveBackToSniffState.MOVE_BACK);
	}
}
